<template>
    <div>
        <el-button type="warning" size="small" id="audit" @click="AuditComment_show=true"><i class="el-icon-finished"></i>审批</el-button>
        <el-button type="success" size="small" id="printBtn" v-print="printObj"><i class="el-icon-printer"></i>打印</el-button>

        <form class="wrapper" id="wrapperApplyPurchaseTable">
            <div class="header">
                <img src="/image/logo.jpg" /><label>固基行远，协晨悟通</label>
            </div>
            <h2 class="Title">固远晨通科技发展有限公司项目资金计划表</h2>
            <table class="report_data" id="LAY-EXPORT-TEST" rules=all>
                <tr class="tr_one">
                    <td class="td_Title">项目名称</td>
                    <td class="td_Content">{{dataProject.ProjectName}}</td> 
                    <td class="td_Title">所属行业</td>
                    <td class="td_Content">{{dataProject.Industry}}</td>
                    <td class="td_Title">项目编号</td>
                    <td class="td_Content">{{dataProject.ProjectNumber}}</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">开始时间</td>
                    <td class="td_Content">{{ fmtDate(dataProject.CreateDate) }}</td>
                    <td class="td_Title">结束时间</td>
                    <td class="td_Content">{{ fmtDate(dataProject.FinishDate) }}</td>
                    <td class="td_Title">项目负责人</td>
                    <td class="td_Content">{{ GetNameByUserId(dataProject.HeadUserId) }}</td>
                </tr>
                <tr class="tr_two">
                    <td class="td_Title">项目类型</td>
                    <td class="td_Content" colspan="6">
                        <el-checkbox-group v-model="ProjectTypeLis" size="medium" disabled>
                            <el-checkbox :label="1" border>施工生产</el-checkbox>
                            <el-checkbox :label="2" border>产品生产</el-checkbox>
                            <el-checkbox :label="4" border>产品研发</el-checkbox>
                            <el-checkbox :label="8" border>技术服务</el-checkbox>
                            <el-checkbox :label="16" border>其它</el-checkbox>
                        </el-checkbox-group>
                    </td>
                </tr>
                <tr class="tr_one" id="HelpDepartment">
                    <td class="td_Title">费用名称</td>
                    <td class="td_Title">费用构成</td>
                    <td class="td_Title">金额（元）</td>
                    <td class="td_Title">费用名称</td>
                    <td class="td_Title">费用构成</td>
                    <td class="td_Title">金额（元）</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">材料费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.MaterialCostDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.MaterialCost}}</td>
                    <td class="td_Title">设备租赁费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.EquipmentRentalFeeDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.EquipmentRentalFee}}</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">新增工具</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.NewToolsDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.NewTools}}</td>
                    <td class="td_Title">设备燃油费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.EquipmentRentalFeeDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.EquipmentRentalFee}}</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">新增设备</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.NewDeviceDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.NewDevice}}</td>
                    <td class="td_Title">维修费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.MaintenanceCostDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.MaintenanceCost}}</td>
                </tr>
                <tr class="tr_one" >
                    <td class="td_Title">办公费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.OfficeExpensesDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.OfficeExpenses}}</td>
                    <td class="td_Title">业务招待费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.BusinessEntertainmentDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.BusinessEntertainment}}</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">差旅费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.TravelExpensesDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.TravelExpenses}}</td>
                    <td class="td_Title">人工费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.LaborCostDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.LaborCost}}</td>
                </tr>
                <tr class="tr_one" >
                    <td class="td_Title">现场人员生活费</td>
                    <td class="td_Content">
                        <el-checkbox-group v-model="LivingExpensesLis" disabled>
                            <el-checkbox label="0" disabled>统一支配</el-checkbox>
                            <el-checkbox label="1" disabled>先行垫付</el-checkbox>
                        </el-checkbox-group>
                    </td>
                    <td class="td_Content">{{ dataProjectCapitalPlan.LivingExpenses }}</td>
                    <td class="td_Title">现场人员住宿费</td>
                    <td class="td_Content">
                        <el-checkbox-group v-model="HotelExpenseLis" disabled>
                            <el-checkbox label="0" disabled>统一支配</el-checkbox>
                            <el-checkbox label="1" disabled>先行垫付</el-checkbox>
                        </el-checkbox-group>
                    </td>
                    <td class="td_Content">{{ dataProjectCapitalPlan.HotelExpense }}</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">劳保物品</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.LabourInsuranceArticlesDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.LabourInsuranceArticles}}</td>
                    <td class="td_Title">运输费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.FreightDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.Freight}}</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">培训费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.TrainingFeeDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.TrainingFee}}</td>
                    <td class="td_Title">咨询费</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.ConsultationFeeDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.ConsultationFee}}</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">其它</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.OtherExpensesDes}}</td>
                    <td class="td_Content">{{dataProjectCapitalPlan.OtherExpenses}}</td>
                    <td class="td_Content" colspan="3"></td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">合计</td>
                    <td class="td_Content" colspan="5">{{ dataTotalPrice }}</td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">计划经营部签批</td>
                    <td colspan="2">
                        <p class="audit" id="audit1">{{ GetNameByUserId(dataProjectCapitalPlan.AuditUserId1) }}</p>
                        <p class="time" id="time1">{{ fmtDate(dataProjectCapitalPlan.AuditTime1) }}</p>
                    </td>
                    <td class="td_Title">运营综合部签批</td>
                    <td colspan="3">
                        <p class="audit" id="audit2">{{ GetNameByUserId(dataProjectCapitalPlan.AuditUserId2) }}</p>
                        <p class="time" id="time2">{{ fmtDate(dataProjectCapitalPlan.AuditTime2) }}</p>
                    </td>
                </tr>
                <tr class="tr_one">
                    <td class="td_Title">财务部签批</td>
                    <td colspan="2">
                        <p class="audit" id="audit3">{{ GetNameByUserId(dataProjectCapitalPlan.AuditUserId3) }}</p>
                        <p class="time" id="time3">{{ fmtDate(dataProjectCapitalPlan.AuditTime3) }}</p>
                    </td>
                    <td class="td_Title">总经理/董事长签批</td>
                    <td colspan="3">
                        <p class="audit" id="audit4">{{ GetNameByUserId(dataProjectCapitalPlan.AuditUserId4) }}</p>
                        <p class="time" id="time4">{{ fmtDate(dataProjectCapitalPlan.AuditTime4) }}</p>
                    </td>
                </tr>
            </table>
            <div class="author"><span>固远晨通科技发展有限公司制</span></div>
            <div id="Footer">
                <div><span style="margin-right: 100px;">固远晨通科技发展有限公司</span><span>网址：<a>www.guyuanct.com</a></span></div>
                <div><span>地址：成都西区大道199号成都模具工业园C1栋</span></div>
            </div>
        </form>

        <el-dialog v-if="AuditComment_show" :modal="false"  :visible.sync="AuditComment_show" width="40%" title="审批" :before-close="onClose">
            <AuditComment ref="AuditCommentRef" :approval-receipt="Approval_event" :approval="Approval"></AuditComment>
        </el-dialog>
    </div>
</template>

<script>
    import AuditComment from "../../AuditComment";
    import * as publicjs from "../../../../public/Scriput/Public";

    export default {
        name: "ProjectFundscheduleTable",
        props: {
            project: {
                type: Object,
                required: true,
            },
        },
        components:{
            AuditComment,
        },
        data(){
            return{
                OneShow:false,
                TwoShow:false,
                printObj: {
                    id: "wrapperApplyPurchaseTable",  //打印标签的id
                    popTitle: '',  //文件标题
                },
                AuditComment_show:false,
                // 审批弹窗返回数据
                Approval: {
                    State: 1,
                    Comment: '',
                },
                dataProject:{},
                dataProjectCapitalPlan:{},
                dataTotalPrice:0,
                GetCompanyAllUsers:[],
                ProjectTypeLis:[],
                //现场人员生活费
                LivingExpensesLis:[],
                //现场人员住宿费
                HotelExpenseLis:[],
            }
        },
        watch:{
            project:function () {
                this.Init()
                this.GetData()
            }
        },
        mounted() {
            let _this = this
            this.$nextTick(()=>{
                _this.Init()
                _this.GetData()
            })
        },
        methods:{
            //数据转换
            fmtDate(val){
                if (val!=null&&val!=''){
                    return val.split(' ')[0]
                }else{
                    return ''
                }
            },
            Init(){
                this.GetCompanyAllUsers = publicjs.GetCompanyAllUsers(this.$http)
            },
            //初始数据加载
            GetData(){
                this.$http.post('Project1/GetProjectCapitalPlanReport',{
                    ProjectId:this.project.Id,
                    Type:1
                }).then(res=>{
                    this.dataProject = res.data.dataProject;
                    this.dataProjectCapitalPlan = res.data.dataProjectCapitalPlan;
                    this.dataTotalPrice = res.data.dataTotalPrice;
                    this.ProjectTypeLis = this.dataProject.ProjectType.toString().split(',').map(x=> parseInt(x))
                    this.LivingExpensesLis = this.dataProjectCapitalPlan.LivingExpensesType.toString().split(',')
                    this.HotelExpenseLis = this.dataProjectCapitalPlan.HotelExpenseType.toString().split(',')
                })
            },
            //根据userid获取userName,主要用于公司人员
            GetNameByUserId(UserId){
                for (let i=0;i<this.GetCompanyAllUsers.length;i++){
                    if (this.GetCompanyAllUsers[i].Id == UserId){
                        return this.GetCompanyAllUsers[i].UserName
                    }
                }
            },
            //审批
            Approval_event(){
                this.$http.post('Project1/AuditProjectCapitalPlanReport',{
                    ProjectId:this.project.Id,
                    Type:1
                }).then(res=>{
                    if (res.data.IsSuccess){
                        this.$message.success(res.data.Msg)
                        this.AuditComment_show=false
                        this.GetData()
                    }else{
                        this.$message.warning(res.data.Msg)
                    }
                })
                this.$refs["AuditCommentRef"].FormClose_event();
            }
        },
        // 关闭审批结果组件
        async onClose(done) {
            await done();
            this.$refs["AuditCommentRef"].FormClose_event();
        },
    }
</script>

<style scoped>
    #audit {
        position: absolute;
        right: 11%;
        top: 80px;
        z-index: 9999;
    }
    #printBtn {
        position: absolute;
        right: 11%;
        top: 115px;
        z-index: 9999;
    }
    /*外包装样式*/
    .wrapper {
        width: 80%;
        height: 100%;
        margin: auto;
    }
    /*页眉样式*/
    .header {
        font-weight: bold;
        font-size: 20px;
        font-family: cursive;
        width: 80%;
        margin: auto;
        border-bottom: 2px solid black;
        padding: 10px 0px;
        position: relative;
    }

    .header img {
        width: 200px;
        height: 55px;
    }

    .header label {
        position: absolute;
        bottom: 10px;
        right: 70px;
    }
    /*标题样式*/
    h2 {
        width: 80%;
        text-align: center;
        font-size: 25px;
        font-weight: bold;
        margin: auto;
        padding: 10px 0;
    }
    /*标题样式*/
    h4 {
        width: 80%;
        text-align: center;
        font-weight: bold;
        margin: auto;
        padding: 10px 0;
    }
    /*数据表格样式*/
    .report_data {
        width: 100%;
        text-align: center;
        border: 1px solid black;
        font-size: 14px;
        word-break: break-all;
    }

    .report_data tr {
        height: 40px;
    }

    .report_data th {
        font-weight: 100;
    }
    .baseInfo .worderWrapper {
        display: inline-block;
        width: 200px;
    }
    .report_audit .tdCenter {
        text-align: center;
    }

    .report_audit tr {
        height: 70px;
    }

    .report_audit tr p {
        padding: 3px;
    }

    .report_audit td {
        padding: 0 10px;
    }

    .report_audit td:first-child {
        width: 150px;
    }

    .report_audit .tr_center {
        text-align: center;
    }

    tr p.audit {
        font: italic bold 20px/30px arial,sans-serif;
        text-align: right;
        /*padding-right: 110px;*/
    }

    tr p.audit span {
        display: inline-block;
        width: 100px;
        font: bold 17px/30px arial,sans-serif;
    }

    tr p.gray {
        color: gray;
    }

    tr p.audit span.red {
        color: red;
    }

    tr p.audit span.blue {
        color: blue;
    }
    .author {
        width: 80%;
        margin: auto;
        margin-top: 5px;
        font-weight: bold;
        text-align: right;
    }
    /*页脚样式*/
    #Footer {
        width: 80%;
        margin: auto;
        border-top: 2px solid black;
        margin-top: 60px;
        font-weight: bold;
    }
    #Footer div {
        padding-top: 5px;
        padding-bottom: 10px;
    }
    #search select {
        text-align: left;
    }
    /*折叠面板样式修改*/
    .layui-collapse .layui-colla-title {
        margin: 0;
        width: 100%;
        text-align: left;
    }
    /*报表管理下统计报表的样式*/
    #EchartData .pie {
        height: 500px;
    }

    #EchartData .pieData {
        float: left;
        width: 50%;
        height: 500px;
    }

    #EchartData .bar {
        width: 100%;
        height: 500px;
    }

    .report_data .tr_one {
        height: 50px;
    }

    .report_data .tr_two {
        height: 100px;
    }

    .report_data .td_Title {
        font-weight: bold;
    }

    .td_left {
        text-align: left;
        padding-left: 20px;
    }

    .td_Content {
        padding: 5Px 5px;
    }

    .report_data .layui-disabled, .report_data .layui-disabled:hover {
        color: black !important;
    }

    .report_data .layui-form-radio > i:hover, .report_data .layui-form-radioed > i {
        color: #5FB878 !important;
    }
</style>
